package hotel.callback.oversea.service.impl;


import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import hotel.base.oversea.utils.*;
import hotel.base.oversea.vo.switchs.*;
import hotel.callback.oversea.config.AsynHttpClientFactory;
import hotel.callback.oversea.config.service.RedisService;
import hotel.callback.oversea.entity.switchs.SwitchCreateRoomEntity;
import hotel.callback.oversea.mapper.SwitchCreateRoomMapper;
import hotel.callback.oversea.mapper.SwitchHotelActiveTagMapper;
import hotel.callback.oversea.mapper.SwitchHotelUpMapper;
import hotel.callback.oversea.mapper.SwitchPriceBaseSetMapper;
import hotel.callback.oversea.service.SwitchPushRoomService;
import hotel.callback.oversea.service.SwitchRestTempaleUtilsService;
import hotel.callback.oversea.service.SwitchRoomPriceService;
import hotel.callback.oversea.vo.BaseRqeuestParam;
import hotel.base.oversea.constant.CallbackConstants;
import hotel.base.oversea.constant.CommonConstants;
import hotel.base.oversea.constant.MeituanConstants;
import hotel.base.oversea.constant.SwitchConstants;
import hotel.base.oversea.constant.enums.MessageEnums;
import hotel.base.oversea.constant.enums.SwitchChannelNameEnums;
import hotel.base.oversea.constant.enums.SwitchSaleStatusEnums;
import hotel.base.oversea.entity.SwitchHotelActiveTagEntity;
import hotel.base.oversea.entity.SwitchPriceBaseSetEntity;
import hotel.base.oversea.service.impl.BaseServiceImpl;
import hotel.base.oversea.vo.BatchPushRoomDatasVo;
import hotel.base.oversea.vo.RoomDataEntityVO;
import hotel.base.oversea.vo.RoomPriceVo;
import hotel.base.oversea.vo.RoomStatusInventory;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.concurrent.FutureCallback;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import sun.misc.BASE64Encoder;

import java.math.BigDecimal;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.*;

/**
 * @Author lmf
 * @Date 2020/6/17 17:33
 **/
@Slf4j
@Service
public class SwitchPushRoomServiceImpl extends BaseServiceImpl implements SwitchPushRoomService {
    @Value("${profile.type}")
    private String profile;
    //定义多线程启动相关配置
    //定义线程池数量
    private static int corePoolSize=Runtime.getRuntime().availableProcessors();
    //corePoolSize：线程池持有的可用的线程数量
    //maximumPoolSize：当队列workQueue满了过后，线程池可用的最大线程数量
    private static ThreadPoolExecutor executor=new ThreadPoolExecutor(corePoolSize,Integer.MAX_VALUE,101, TimeUnit.SECONDS,new LinkedBlockingDeque<>(1000));

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private SwitchRoomPriceService switchRoomPriceService;

    @Autowired
    private SwitchRestTempaleUtilsService switchRestTempaleUtilsService;

    @Autowired
    SwitchPriceBaseSetMapper switchPriceBaseSetMapper;

    @Autowired
    SwitchCreateRoomMapper switchCreateRoomMapper;

    @Autowired
    SwitchHotelActiveTagMapper switchHotelActiveTagMapper;

    @Autowired
    RedisService redisService;

    @Autowired
    RedisTemplate redisTemplate;

    @Autowired
    private SwitchHotelUpMapper switchHotelUpMapper ;
    /**
     * 定义key保存消费的key
     */
    private final  static String SPEND_DTAA_KEY="spend_data_key_";
    /**
     * @author: lmf
     * @date: 2020/8/27 21:28
     * 多线程批量推送售卖房型房态价格变更记录
     */
    @Override
    public Result<Object> manyThreadPushRoomData() {
        BatchPushRoomDatasVo batchPushRoomDatasVo = new BatchPushRoomDatasVo();
        long startTime = System.currentTimeMillis();
        //线程数量
        String key = CommonConstants.SWITCH_PUSH_ROOM_THREAD_NUM;
        int num = 5;
        if (redisService.exists(key)) {
            num = (int) redisService.get(key);
        } else {
            redisService.set(key, 5);
        }
        if(redisService.exists("switch_push_price_and_status_size")){
            redisService.remove("switch_push_price_and_status_size");
        }
        ExecutorService executorService = Executors.newFixedThreadPool(num);
        List<Future<Result<Object>>> threads = new ArrayList<>();
        int dataSize=0;
        for (int i = 1; i <= num; i++) {
            String batchPushRoomDatasVoStr = "";
           synchronized (this) {
                //取数据问题
                batchPushRoomDatasVoStr = (String) redisTemplate.opsForList().rightPop(MeituanConstants.REDIS_CHANGE_GOODS_DATA_MANY_HOTEL);
                dataSize++;
            }
            log.info("================manyThreadPushRoomData缓存中可推送的数据长度为{}", redisTemplate.opsForList().size(MeituanConstants.REDIS_CHANGE_GOODS_DATA_MANY_HOTEL));
            //batchPushRoomDatasVoStr="{\"compare\":1,\"mtHotelId\":180544511,\"roomDataEntityList\":[{\"goodId\":62003370,\"goodInventory\":1,\"roomPrices\":[{\"date\":\"2021-05-07\",\"salePrice\":38800,\"subPrice\":3104}]},{\"goodId\":62003368,\"goodInventory\":1,\"roomPrices\":[{\"date\":\"2021-05-07\",\"salePrice\":19300,\"subPrice\":1544}]}],\"timestamp\":\"1620378610935103844\"}";
            if (StringUtils.isEmpty(batchPushRoomDatasVoStr)) {
                break;
            }
            batchPushRoomDatasVo = JacksonUtil.parse(batchPushRoomDatasVoStr, BatchPushRoomDatasVo.class);
            if (ObjectUtils.isEmpty(batchPushRoomDatasVo)) {
                break;
            }
            Future<Result<Object>> result = executorService.submit(new spider("推送价格房态房态库存推送线程" + i, batchPushRoomDatasVo));
            threads.add(result);
        }
        executorService.shutdown();
        long endTime=System.currentTimeMillis();
        while(true){
            if(executorService.isTerminated()){
                log.info("====执行结束了======");
                break;
            }
        }
        Long size=redisTemplate.opsForList().size(MeituanConstants.REDIS_CHANGE_GOODS_DATA_MANY_HOTEL);
        int  success= (int) redisService.get("switch_push_price_and_status_size");
        if(redisService.exists("is_open_msg_push_size")){
            new MsgThreadBookThread("当前推送了"+dataSize+"条数据"+">>>还剩"+size+"条待消费>>>"+",此次推送成功推送有"+success+"条数据").run();
        }
        log.info("===========整个推送花费推送花费的时间为{}",(endTime-startTime));
        return new Result<>("推送房型价格库存房态数据成功");
    }



    /**
     * 用来推送价格房态的定时任务
     */
    class spider implements Callable<Result<Object>> {
        String threadName;
        BatchPushRoomDatasVo batchPushRoomDatasVo;

        public spider(String threadName,BatchPushRoomDatasVo batchPushRoomDatasVo) {
            this.threadName = threadName;
            this.batchPushRoomDatasVo=batchPushRoomDatasVo;

        }
        @Override
        public Result<Object> call() {
            return notityModifyRoomInfo2(batchPushRoomDatasVo);
        }
    }
    /***
    * @Author: lmf
    * @Date: 2021/4/20
     * 封装推送数据给携程
    */
    @Override
    public Result<Object> makePushRoomData() {
        //线程数量
        //每次封装30条数据
        String key = "switch_mark_push_room_data_num";
        int num = 30;
        if (redisService.exists(key)) {
            num = (int) redisService.get(key);
        }
        BatchPushRoomDatasVo batchPushRoomDatasVo =null;
        String batchPushRoomDatasVoStr = "";
        for (int i = 1; i <= num; i++) {
            batchPushRoomDatasVoStr = (String) redisTemplate.opsForList().rightPop(MeituanConstants.REDIS_CHANGE_GOODS_DATA_MANY_HOTEL);
            log.info("================manyThreadPushRoomData缓存中可封装的数据长度为{}", redisTemplate.opsForList().size(MeituanConstants.REDIS_CHANGE_GOODS_DATA_MANY_HOTEL));
            //batchPushRoomDatasVoStr="{\"compare\":0,\"mtHotelId\":50315865,\"roomDataEntityList\":[{\"goodId\":652768557,\"goodInventory\":1,\"roomPrices\":[{\"date\":\"2021-04-21\",\"salePrice\":21300,\"subPrice\":1704},{\"date\":\"2021-04-22\",\"salePrice\":21300,\"subPrice\":1704}]},{\"goodId\":652696977,\"goodInventory\":1,\"roomPrices\":[{\"date\":\"2021-04-21\",\"salePrice\":24100,\"subPrice\":1928},{\"date\":\"2021-04-22\",\"salePrice\":24100,\"subPrice\":1928}]},{\"goodId\":637480583,\"goodInventory\":1,\"roomPrices\":[{\"date\":\"2021-04-21\",\"salePrice\":21500,\"subPrice\":1720},{\"date\":\"2021-04-22\",\"salePrice\":21500,\"subPrice\":1720}]}],\"timestamp\":\"1618990791892103524\"}";
            if (StringUtils.isEmpty(batchPushRoomDatasVoStr)) {
                break;
            }
            batchPushRoomDatasVo = JacksonUtil.parse(batchPushRoomDatasVoStr, BatchPushRoomDatasVo.class);
            if (ObjectUtils.isEmpty(batchPushRoomDatasVo)) {
                break;
            }
            constructionRequestData(batchPushRoomDatasVo);
        }

        return new Result<>("推送房型价格库存房态数据成功");
    }
    /***
    * @Author: lmf
    * @Date: 2021/4/20
     * 消费数据推送给携程
    */
    @Override
    public Result<Object> pushRoomToSwitch() {
        Long size=redisTemplate.opsForList().size(CommonConstants.SWITCH_CALLBACK_PUSH_DATA_QUEUE);
        if(redisService.exists("switch_push_room_to_switch_success_size")){
            Long success= redisService.listSize("switch_push_room_to_switch_success_size");
            if(redisService.exists("is_open_msg_push_size")){
                new MsgThreadBookThread("队列还剩"+size+"条待消费>>>"+",上次推送成功推送有"+success+"条数据").run();
            }
            redisService.remove("switch_push_room_to_switch_success_size");
        }
        //线程数量
        String key = CommonConstants.SWITCH_PUSH_ROOM_THREAD_NUM;
        int num = 8;
        if (redisService.exists(key)) {
            num = (int) redisService.get(key);
        }
        List<BatchPushRoomDataVo> batchPushRoomDataVos=new ArrayList<>();
        BatchPushRoomDataVo batchPushRoomDataVo=null;
        log.info("=======推送携程队列长度为{}========",redisTemplate.opsForList().size(CommonConstants.SWITCH_CALLBACK_PUSH_DATA_QUEUE));
        for(int i = 0;i<num;i++){
            String batchPushRoomDatasVoStr= (String) redisTemplate.opsForList().rightPop(CommonConstants.SWITCH_CALLBACK_PUSH_DATA_QUEUE);
            if (StringUtils.isEmpty(batchPushRoomDatasVoStr)) {
                break;
            }
            batchPushRoomDataVo=GsonUtils.GsonToBean(batchPushRoomDatasVoStr,BatchPushRoomDataVo.class);
            if (ObjectUtils.isEmpty(batchPushRoomDataVo)) {
                break;
            }
            batchPushRoomDataVos.add(batchPushRoomDataVo);
        }
        //获取数据发送数据请求
        final CountDownLatch latch = new CountDownLatch(batchPushRoomDataVos.size());
        CloseableHttpAsyncClient client= AsynHttpClientFactory.getCloseableHttpAsyncClient();
        BaseRqeuestParam baseRqeuestParam=null;
        for(BatchPushRoomDataVo e:batchPushRoomDataVos){
            baseRqeuestParam=new BaseRqeuestParam();
            log.info("=======时间戳为{}数据为{}======",e.getTimeStamp(), JSONUtils.toJSONString(e.getBatchPushRoomVo()));
            Map<String,Object> requestParam=new HashMap<>();
            requestParam.put("roomDataEntitys",e.getBatchPushRoomVo().getRoomDataEntitys());
            requestParam.put("hotelId",e.getBatchPushRoomVo().getHotelId());
            ObjectMapper objectMapper = new ObjectMapper();
            requestParam.put("requestor", baseRqeuestParam);
            int supplierID=profile.equals("test")? SwitchConstants.SUPPLIERID_TEST:SwitchConstants.SUPPLIERID_PROD;
            requestParam.put("supplierID", supplierID);
            //获取 timestamp
            String timestamp = String.valueOf(System.currentTimeMillis());
            //计算 signature
            String tmp = String.valueOf(supplierID) + String.valueOf(System.currentTimeMillis()) + (profile.equals("test")?SwitchConstants.KEY_TEST:SwitchConstants.KEY_PROD);
            MessageDigest md5= null;
            try {
                md5 = MessageDigest.getInstance("MD5");
                BASE64Encoder base64en = new BASE64Encoder();
                String signature = base64en.encode(md5.digest(tmp.getBytes("utf-8"))).toUpperCase();
                //组装 http 请求数据
                String httpUrl=(profile.equals("test")?SwitchConstants.URL_TEST:SwitchConstants.URL_PROD)+"BatchPushRoomData";
                HttpPost httpPost=new HttpPost(httpUrl);
                httpPost.setHeader(HTTP.CONTENT_TYPE, "application/json");
                httpPost.setHeader("timestamp", timestamp);
                httpPost.setHeader("signature", signature);
                httpPost.setEntity(new StringEntity(objectMapper.writeValueAsString(requestParam),
                        ContentType.create("text/json", "UTF-8")));
                client.execute(httpPost, new FutureCallback<HttpResponse>() {
                    @SneakyThrows
                    @Override
                    public void completed(HttpResponse httpResponse) {
                        latch.countDown();
                        log.info("=========时间戳为{}推送的数据为{}",e.getTimeStamp(),JacksonUtil.objectToJson(e.getBatchPushRoomVo()));
                        HttpEntity httpEntity=httpResponse.getEntity();
                        String result = EntityUtils.toString(httpEntity);
                        String httpUrl=(profile.equals("test")?SwitchConstants.URL_TEST:SwitchConstants.URL_PROD)+"BatchPushRoomData";
                        log.info("请求的url是{}",httpUrl);
                        log.info("pushRoomToSwitch>>>请求数据是{}",objectMapper.writeValueAsString(requestParam));
                        log.info("pushRoomToSwitch>>>返回数据是{}",result);
                        if(result.contains("太频繁")||result.contains("签名验证失败")){
                            log.info("===========推送携程太频繁或者签名验证失败,放回队列执行=============");
                            redisService.lPush(CommonConstants.SWITCH_CALLBACK_PUSH_DATA_QUEUE,GsonUtils.GsonString(e));
                        }else{
                           redisService.lPush("switch_push_room_to_switch_success_size",1);
                        }
                    }

                    @Override
                    public void failed(Exception e) {
                        latch.countDown();
                        log.info("=============httpResponse调用失败返回的信息为为{}=====",e.getMessage());
                    }

                    @Override
                    public void cancelled() {
                        latch.countDown();
                        log.info("=============httpResponse调用失败返回的信息为为=====");
                    }
                });
            } catch (Exception e1) {
               e1.printStackTrace();
            }
        }
        return new Result<>();
    }



    /**
     * 最新代码优化
     * @param batchPushRoomDatasVo
     * @return
     */
    public  Result<Object> notityModifyRoomInfo2(BatchPushRoomDatasVo batchPushRoomDatasVo) {
        log.info("=============进入构造方法的请求数据，时间戳为{}数据为{}",batchPushRoomDatasVo.getTimestamp(), JSON.toJSONString(batchPushRoomDatasVo));
        String channel = StringUtil.firstToUpperCase(SwitchChannelNameEnums.CTRIP.getName());
        String qunar = StringUtil.firstToUpperCase(SwitchChannelNameEnums.QUNAR.getName());
        String b2bChannel=StringUtil.firstToUpperCase(SwitchChannelNameEnums.BIG_B2B.getName());
        //String channelChannel=StringUtil.firstToUpperCase(SwitchChannelNameEnums.BIG_CHANNEL_A.getName());
        //获取携程子酒店信息
        List<RoomDataEntityVo> roomDataEntityVos=new ArrayList<>();
        Map<String, List<SwitchPriceBaseSetEntity>> switchPriceBaseSetMap=getOnlinePriceSet();
        //遍历美团产品列表
        int hotelId=0;
        int swHotelId=0;//携程酒店id
        int masterHotelId=0;//携程母酒店酒店id
        int swRoomId=0;//携程售卖房型id
        String mtRoomId="";//美团产品所属房型id
        Integer addPrice=0;
        Double addRate=1.0;
        //控制天天活动 open_join_acive_list 有值代表有开启天天特价
        if(redisService.exists("open_join_acive_list")){
            //初始化活动数据
            if(!redisService.exists(CommonConstants.SWITCH_JOIN_ACTIVE_HOTEL_LIST_FOR_ORDER)){
                List<Integer> list=switchHotelUpMapper.selectJoinActiveHotelList();
                if(!ObjectUtils.isEmpty(list)&&list.size()>0){
                    String key=CommonConstants.SWITCH_JOIN_ACTIVE_HOTEL_LIST_FOR_ORDER;
                    Integer price=5000;
                    if(redisService.exists(CommonConstants.SWITCH_JOIN_ACTIVE_HOTEL_PRICE)){
                        price= (Integer) redisService.get(CommonConstants.SWITCH_JOIN_ACTIVE_HOTEL_PRICE);
                    }
                    String finalKey = key;
                    Integer finalPrice = price;
                    list.forEach(e->{
                        redisService.hmSet(finalKey,e,finalPrice);
                    });
                }
            }
            //是否参与天天特价
            addPrice= (Integer) redisService.hmGet(CommonConstants.SWITCH_JOIN_ACTIVE_HOTEL_LIST_FOR_ORDER,batchPushRoomDatasVo.getMtHotelId());
        }
        //控制折扣活动 如:特惠出行
        if(redisService.exists("open_join_acive_rate_list")){
            //初始化活动数据
            if(!redisService.exists(CommonConstants.SWITCH_HOTEL_ACTIVE_LIST_BY_OPEN_ACTIVE)){
                List<Map<String,String>> list=switchHotelUpMapper.selectJoinActiveHotelRateList();
                if(!ObjectUtils.isEmpty(list)&&list.size()>0){
                    String key=CommonConstants.SWITCH_HOTEL_ACTIVE_LIST_BY_OPEN_ACTIVE;
                    String finalKey = key;
                    list.forEach(e->{
                        try{
                            Integer mtHotelId=Integer.valueOf(String.valueOf(e.get("mt_hotel_id")));
                            double rate= Double.parseDouble(String.valueOf(e.get("rate")));
                            redisService.hmSet(finalKey,mtHotelId,rate);
                        }catch (Exception e2){
                            e2.printStackTrace();
                        }
                    });
                }
            }
            //是否参与促销活动
            addRate= (Double) redisService.hmGet(CommonConstants.SWITCH_HOTEL_ACTIVE_LIST_BY_OPEN_ACTIVE,batchPushRoomDatasVo.getMtHotelId());
        }
        //携程
        RoomDataEntityVo roomDataEntityVo = null;
        //去哪儿
        RoomDataEntityVo qunarRoomDataEntityVo=null;
        //b2b
        RoomDataEntityVo b2bRoomDataEntityVo=null;
        //channelA
        RoomDataEntityVo channelRoomDataEntityVo=null;
        //根据产品id + 美团的酒店id 获取数据
        String key="";
        int roomDataEntityListSize=batchPushRoomDatasVo.getRoomDataEntityList().size();
        RoomDataEntityVO roomDataEntityVO;
        int i=0;
        Map maps=null;
        String messageTotal="";
       tab:for(i=0;i<roomDataEntityListSize;i++) {
            roomDataEntityVO=batchPushRoomDatasVo.getRoomDataEntityList().get(i);
            //根据产品id + 美团的酒店id 获取数据
            key= CommonConstants.SWITCH_SELLING_REDIS_BY_MT+batchPushRoomDatasVo.getMtHotelId()+"_"+roomDataEntityVO.getGoodId();
            //判斷是否存在
            if(redisService.exists(key)){
                maps= (Map) redisService.get(key);
                swHotelId = Integer.valueOf(maps.get("switchHotelId").toString());
                swRoomId = Integer.valueOf(maps.get("switchRoomId").toString());
            }else{
                SwitchCreateRoomEntity switchCreateRoomEntityNew = switchCreateRoomMapper.selectByMtGoodsIdAndHotelId(batchPushRoomDatasVo.getMtHotelId(), roomDataEntityVO.getGoodId());
                if(ObjectUtils.isEmpty(switchCreateRoomEntityNew) || ObjectUtils.isEmpty(switchCreateRoomEntityNew.getMasterHotelId())){
                    continue tab;
                }
                swHotelId = switchCreateRoomEntityNew.getHotelId();
                masterHotelId = switchCreateRoomEntityNew.getMasterHotelId();
                swRoomId = switchCreateRoomEntityNew.getRoomId();
                mtRoomId = switchCreateRoomEntityNew.getMtRoomId();
                maps=new HashMap();
                maps.put("switchHotelId", swHotelId);
                maps.put("switchMasterHotelId", masterHotelId);
                maps.put("switchRoomId", swRoomId);
                maps.put("mtRoomId", mtRoomId);
                redisService.set(key,maps);
            }
            //是否开启获取酒店有独立的价格公式
            if(redisService.exists(CommonConstants.SWITCH_IS_OPEN_HOTEL_OWNER_PRICE_FORMULA)){
                //获取酒店是否有自已独立的价格公式
                switchPriceBaseSetMap=getOnlinePriceSetByData(swHotelId,switchPriceBaseSetMap);
            }
            messageTotal+=swRoomId+",";
            hotelId=swHotelId;
           Integer rate= (Integer) redisService.hmGet(CommonConstants.SWITCH_ADJUST_HOTEL_RATE_BY_OUT_PUT_IS_ZERO,swHotelId);
           if(!ObjectUtils.isEmpty(rate)){
               switchPriceBaseSetMap.entrySet().forEach(e->{
                   List<SwitchPriceBaseSetEntity> switchPriceBaseSetEntities= e.getValue();
                   for(SwitchPriceBaseSetEntity switchPriceBaseSetEntity:switchPriceBaseSetEntities){
                       //最低只能到10
                       if(switchPriceBaseSetEntity.getRate().doubleValue()>10){
                           switchPriceBaseSetEntity.setRate(BigDecimal.valueOf(switchPriceBaseSetEntity.getRate().doubleValue()-rate.doubleValue()));
                       }
                   }
                   e.setValue(switchPriceBaseSetEntities);
               });
           }
            //有价格变动数据
            if (!ObjectUtils.isEmpty(roomDataEntityVO.getRoomPrices()) && roomDataEntityVO.getRoomPrices().size() > 0) {
                //携程价格实体
                RoomPriceModelVo roomPriceModelVo=null;
                //去哪儿价格实体
                RoomPriceModelVo qunarRoomPriceModelVo = null;
                //b2b价格实体
                RoomPriceModelVo b2bRoomPriceModelVo =null;
                //channel价格实体
                RoomPriceModelVo channelRoomPriceModelVo = null;
                String switchHotelActiveTagVal="";
                String keys="";
                SwitchHotelActiveTagEntity switchHotelActiveTagEntity=null;
                Map switchHotelActiveTagMap=null;
                String currentWeekDay="";
                int roomPirceSize=roomDataEntityVO.getRoomPrices().size();
                RoomPriceVo roomPriceVo=null;
                int j=0;
                double price=0.00;
                double priceBychannel=0.00;
                double addPrices=0.00;
                if(!ObjectUtils.isEmpty(addPrice)){
                    addPrices=addPrice.doubleValue()/100;
                }
                Map<String,Object> map=null;
                for (j=0;j<roomPirceSize;j++) {
                     roomPriceVo=roomDataEntityVO.getRoomPrices().get(j);
                    //携程
                    roomDataEntityVo = new RoomDataEntityVo();
                    roomDataEntityVo.setRoomId(swRoomId);
                    roomDataEntityVo.setStartDate(roomPriceVo.getDate());
                    roomDataEntityVo.setEndDate(roomPriceVo.getDate());
                    //去哪儿
                     qunarRoomDataEntityVo=new RoomDataEntityVo();
                     qunarRoomDataEntityVo.setRoomId(swRoomId);
                     qunarRoomDataEntityVo.setStartDate(roomPriceVo.getDate());
                     qunarRoomDataEntityVo.setEndDate(roomPriceVo.getDate());
                    //b2b
                    b2bRoomDataEntityVo=new RoomDataEntityVo();
                     b2bRoomDataEntityVo.setRoomId(swRoomId);
                     b2bRoomDataEntityVo.setStartDate(roomPriceVo.getDate());
                     b2bRoomDataEntityVo.setEndDate(roomPriceVo.getDate());
                    //channelA
                     channelRoomDataEntityVo=new RoomDataEntityVo();
                     channelRoomDataEntityVo.setRoomId(swRoomId);
                     channelRoomDataEntityVo.setStartDate(roomPriceVo.getDate());
                    channelRoomDataEntityVo.setEndDate(roomPriceVo.getDate());
                    //判断是否参加促销活动
                    //促销
                    map=new HashMap<>();
                    //roomPriceVo.getDate()
                    if( !ObjectUtils.isEmpty(switchHotelActiveTagEntity)&&!ObjectUtils.isEmpty(switchHotelActiveTagEntity.getStartTime())&& DateUtil.commpareDay(switchHotelActiveTagEntity.getStartTime(),roomPriceVo.getDate())&&DateUtil.commpareDay(roomPriceVo.getDate(),switchHotelActiveTagEntity.getEndTime())){
                        map=getPriceV2(switchPriceBaseSetMap,roomPriceVo.getSalePrice(),roomPriceVo.getSubPrice(),switchHotelActiveTagEntity);
                    }else{
                        map=getPriceV2(switchPriceBaseSetMap,roomPriceVo.getSalePrice(),roomPriceVo.getSubPrice(),null);
                    }
                    /**
                     * 计算携程推送价格
                     */
                    price = (Double.parseDouble(map.get("ctripPrice").toString())+addPrices)/addRate;
                    priceBychannel = (Double.parseDouble(map.get("qunarPrice").toString())+addPrices)/addRate;
                    //携程价格实体
                    roomPriceModelVo = new RoomPriceModelVo();
                    roomPriceModelVo.setRoomPrice(price);
                    roomPriceModelVo.setCurrency("CNY");
                    roomPriceModelVo.setChannel(channel);
                    roomDataEntityVo.setRoomPriceModel(roomPriceModelVo);
                    //去哪儿价格实体
                    qunarRoomPriceModelVo = new RoomPriceModelVo();
                    qunarRoomPriceModelVo.setRoomPrice(priceBychannel);
                    qunarRoomPriceModelVo.setCurrency("CNY");
                    qunarRoomPriceModelVo.setChannel(qunar);
                    qunarRoomDataEntityVo.setRoomPriceModel(qunarRoomPriceModelVo);
                    //b2b价格实体
                    b2bRoomPriceModelVo = new RoomPriceModelVo();
                    b2bRoomPriceModelVo.setRoomPrice(priceBychannel);
                    b2bRoomPriceModelVo.setCurrency("CNY");
                    b2bRoomPriceModelVo.setChannel(b2bChannel);
                    b2bRoomDataEntityVo.setRoomPriceModel(b2bRoomPriceModelVo);
                    //channel价格实体
                  /*  channelRoomPriceModelVo = new RoomPriceModelVo();
                    channelRoomPriceModelVo.setRoomPrice(priceBychannel);
                    channelRoomPriceModelVo.setCurrency("CNY");
                    channelRoomPriceModelVo.setChannel(channelChannel);
                    channelRoomDataEntityVo.setRoomPriceModel(channelRoomPriceModelVo);*/
                    //有库存房态变化
                    if (!ObjectUtils.isEmpty(roomDataEntityVO.getRoomStatusInventorys()) && roomDataEntityVO.getRoomStatusInventorys().size() > 0) {
                        roomDataEntityVo=getStatusInfo(batchPushRoomDatasVo.getTimestamp(),roomDataEntityVO.getRoomStatusInventorys(),channel,roomPriceVo.getDate(),roomDataEntityVo);
                    }
                    //推送价格记录表 保存房型推送数据实体数据
                    roomDataEntityVos.add(roomDataEntityVo);
                    roomDataEntityVos.add(qunarRoomDataEntityVo);
                    roomDataEntityVos.add(b2bRoomDataEntityVo);
                    //channel渠道推送价格无用，暂时关闭
                  //  roomDataEntityVos.add(channelRoomDataEntityVo);
                }

            } else {//说明只有库存和房态变化
                RoomStatusModelVo roomStatusModelVo=null;
                RoomInventoryModelVo roomInventoryModelVo=null;
                //设置房态房量
                for (RoomStatusInventory roomStatusInventory : roomDataEntityVO.getRoomStatusInventorys()) {
                    roomDataEntityVo = new RoomDataEntityVo();
                    roomDataEntityVo.setRoomId(swRoomId);
                    roomDataEntityVo.setStartDate(roomStatusInventory.getDate());
                    roomDataEntityVo.setEndDate(roomStatusInventory.getDate());
                    //房态
                    roomStatusModelVo = new RoomStatusModelVo();
                    roomStatusModelVo.setChannel(channel);
                    if (roomStatusInventory.getGoodStatus() == 1) {
                        roomInventoryModelVo=new RoomInventoryModelVo();
                        roomInventoryModelVo.setPreservedQuantity(0);
                        roomInventoryModelVo.setPushPreservedType(4);
                        roomInventoryModelVo.setUnPreservedQuantity(1);
                        roomInventoryModelVo.setPushUnPreservedType(4);
                        roomInventoryModelVo.setAutoCloseRoom(1);
                        roomInventoryModelVo.setChannel(channel);
                        roomStatusModelVo.setSaleStatus(SwitchSaleStatusEnums.SALE.getCode());
                        roomDataEntityVo.setRoomInventoryModel(roomInventoryModelVo);
                    } else {
                        roomInventoryModelVo=new RoomInventoryModelVo();
                        roomInventoryModelVo.setPreservedQuantity(0);
                        roomInventoryModelVo.setPushPreservedType(4);
                        roomInventoryModelVo.setUnPreservedQuantity(1);
                        roomInventoryModelVo.setPushUnPreservedType(4);
                        roomInventoryModelVo.setAutoCloseRoom(1);
                        roomInventoryModelVo.setChannel(channel);
                        roomDataEntityVo.setRoomInventoryModel(roomInventoryModelVo);
                        messageTotal+=roomStatusInventory.getDate()+",";
                        roomStatusModelVo.setSaleStatus(SwitchSaleStatusEnums.FULL.getCode());
                    }
                    roomDataEntityVo.setRoomStatusModel(roomStatusModelVo);
                    roomDataEntityVos.add(roomDataEntityVo);
                }
            }
        }
        BatchPushRoomVo batchPushRoomVo=new BatchPushRoomVo();
        batchPushRoomVo.setHotelId(hotelId);
        if(ObjectUtils.isEmpty(roomDataEntityVos)||roomDataEntityVos.size()<1){
            log.info("==============时间戳为{},推送的数据实体为空",batchPushRoomDatasVo.getTimestamp());
            return new Result<>("推送的数据实体为空");
        }
        List<List<RoomDataEntityVo>> RoomDataEntityVoLists= ListUtils.parititon(roomDataEntityVos,299);
        int size=0;
        Result<Object> result;
        StringBuffer roomIds=new StringBuffer();
        String msg="";
        boolean f=false;
        for(List<RoomDataEntityVo> roomDataEntityVos1:RoomDataEntityVoLists){
            batchPushRoomVo.setRoomDataEntitys(roomDataEntityVos1);
            log.info("=========时间戳为{}推送的数据为{}",batchPushRoomDatasVo.getTimestamp(),JacksonUtil.objectToJson(batchPushRoomVo));
           // result=new Result<>();
            result=pushRoom(batchPushRoomVo,batchPushRoomDatasVo.getTimestamp());
            roomIds.append(batchPushRoomVo.getRoomDataEntitys().get(0).getRoomId());
            roomIds.append(",");
            msg+=String.valueOf(batchPushRoomVo.getRoomDataEntitys().get(0).getRoomId())+":"+result.getMsg();
            messageTotal+=result.getMsg()+",";
            if(result.getCode()==CommonConstants.SUCCESS){
                int success=0;
                if(redisService.exists("switch_push_price_and_status_size")){
                    success= (int) redisService.get("switch_push_price_and_status_size");
                }
                success=success+1;
                redisService.set("switch_push_price_and_status_size",success);
                size++;
            }else if(result.getMsg().toString().contains("数据重复")){
                int success=0;
                if(redisService.exists("switch_push_price_and_status_size")){
                    success= (int) redisService.get("switch_push_price_and_status_size");
                }
                success=success+1;
                redisService.set("switch_push_price_and_status_size",success);
                size++;
            }else if(result.getMsg().toString().contains("请求过于频繁")||result.getMsg().toString().contains("接口认证失败，认证时间超时")){
                f=true;
            }
        }
        //删除缓存推送全量价格房态：
        //如果有值说明是推全量
      /*  if(isFull){
            new pushHotelLogThread(hotelId).run();
        }*/
        //如果推送提示请求过于频繁，请降低访问次数,进行重试
        if(f){
            redisTemplate.opsForList().leftPush(MeituanConstants.REDIS_CHANGE_GOODS_DATA_MANY_HOTEL, JSON.toJSONString(batchPushRoomDatasVo));
            /*Calendar calendar=Calendar.getInstance();
            int time=calendar.get(Calendar.HOUR_OF_DAY);
            if(time>=10&&time<=18){
                //删除key
                Integer mtHotelId=batchPushRoomDatasVo.getMtHotelId();
                List<RoomDataEntityVO> roomDataEntityList=batchPushRoomDatasVo.getRoomDataEntityList();
                for(RoomDataEntityVO roomDataEntityvo:roomDataEntityList){
                    List<RoomPriceVo> roomPrices=roomDataEntityvo.getRoomPrices();
                    if(!ObjectUtils.isEmpty(roomPrices)&&roomPrices.size()>0){
                        for(RoomPriceVo roomPriceVo:roomPrices){
                            String keys= CallbackConstants.REDIS_KEY_CALLBACK_CHANGE_PRICE_HEAD+mtHotelId+"_"+roomDataEntityvo.getGoodId()+"_"+roomPriceVo.getDate();
                            if(redisService.exists(keys)){
                                redisService.remove(keys);
                            }
                        }
                    }
                    List<RoomStatusInventory> statusInventories=roomDataEntityvo.getRoomStatusInventorys();
                    if(!ObjectUtils.isEmpty(statusInventories)&&statusInventories.size()>0){
                        for(RoomStatusInventory statusInventory:statusInventories){
                            String keys= CallbackConstants.REDIS_KEY_CALLBACK_CHANGE_STATUS_HEAD+mtHotelId+"_"+roomDataEntityvo.getGoodId()+"_"+statusInventory.getDate();
                            if(redisService.exists(keys)){
                                redisService.remove(keys);
                            }
                        }
                    }
                }
            }else{
                redisTemplate.opsForList().leftPush(MeituanConstants.REDIS_CHANGE_GOODS_DATA_MANY_HOTEL,JSON.toJSONString(batchPushRoomDatasVo));
            }*/
        }
/*        //放入到队列里面
        if(batchPushRoomDatasVo.getCompare()==1){
            String keys=CommonConstants.SWITCH_SALE_HOTEL_CHECK_PRICE_AND_STATUS_IS_CHANGE;
            List<Integer> hotelList=new ArrayList<>();
            if(redisService.exists(keys)){
                String json= (String) redisService.get(key);
                hotelList=JacksonUtil.jsonToList(json,Integer.class);
            }
            hotelList.add(hotelId);
            if(!ObjectUtils.isEmpty(hotelList)&&hotelList.size()>0){
                redisService.set(keys,JacksonUtil.objectToJson(hotelList));
            }
        }*/
        Calendar calendar=Calendar.getInstance();
        calendar.setTime(new Date());
        log.info("===========当前分钟是{},秒数是{}====",calendar.get(Calendar.MINUTE),calendar.get(Calendar.SECOND));
        if(!redisService.exists("is_open_msg_push")){
            new MsgThread(batchPushRoomVo.getHotelId(),roomIds.toString(),batchPushRoomDatasVo.getMtHotelId(),batchPushRoomDatasVo.getTimestamp(),"时间戳为"+batchPushRoomDatasVo.getTimestamp()+msg).run();
        }
        return new Result<>();
       /* new MsgThreadBookThread(batchPushRoomVo.getHotelId(),batchPushRoomDatasVo.getTimestamp(),messageTotal).run();*/
      /*  if(size==RoomDataEntityVoLists.size()){
            return new Result<>();
        }else{
            return new Result<>("部分数据没有推送成功",CommonConstants.SUCCESS);
        }*/
    }
    /***
     * @Author: lmf
     * @Date: 2021/4/19
     * 最新代码优化
     * @param batchPushRoomDatasVo
     * @return
     */
    public  Result<Object> notityModifyRoomInfo(BatchPushRoomDatasVo batchPushRoomDatasVo) {
        log.info("=============进入构造方法的请求数据，时间戳为{}数据为{}",batchPushRoomDatasVo.getTimestamp(), JSON.toJSONString(batchPushRoomDatasVo));
        String channel = StringUtil.firstToUpperCase(SwitchChannelNameEnums.CTRIP.getName());
        String qunar = StringUtil.firstToUpperCase(SwitchChannelNameEnums.QUNAR.getName());
        String b2bChannel=StringUtil.firstToUpperCase(SwitchChannelNameEnums.BIG_B2B.getName());
        //获取携程子酒店信息
        List<RoomDataEntityVo> roomDataEntityVos=new ArrayList<>();
        Map<String, List<SwitchPriceBaseSetEntity>> switchPriceBaseSetMap=getOnlinePriceSet();
        //遍历美团产品列表
        int hotelId=0;
        int swHotelId=0;//携程酒店id
        int masterHotelId=0;//携程母酒店酒店id
        int swRoomId=0;//携程售卖房型id
        String mtRoomId="";//美团产品所属房型id
        //是否参与天天特价
        Integer addPrice= (Integer) redisService.hmGet(CommonConstants.SWITCH_JOIN_ACTIVE_HOTEL_LIST_FOR_ORDER,batchPushRoomDatasVo.getMtHotelId());
        //携程
        RoomDataEntityVo roomDataEntityVo = null;
        //去哪儿
        RoomDataEntityVo qunarRoomDataEntityVo=null;
        //b2b
        RoomDataEntityVo b2bRoomDataEntityVo=null;
        //channelA
        RoomDataEntityVo channelRoomDataEntityVo=null;
        //根据产品id + 美团的酒店id 获取数据
        String key="";
        int roomDataEntityListSize=batchPushRoomDatasVo.getRoomDataEntityList().size();
        RoomDataEntityVO roomDataEntityVO;
        int i=0;
        Map maps=null;
        BatchPushRoomVo batchPushRoomVo=new BatchPushRoomVo();
        tab:for(i=0;i<roomDataEntityListSize;i++) {
            roomDataEntityVO=batchPushRoomDatasVo.getRoomDataEntityList().get(i);
            //根据产品id + 美团的酒店id 获取数据
            key= CommonConstants.SWITCH_SELLING_REDIS_BY_MT+batchPushRoomDatasVo.getMtHotelId()+"_"+roomDataEntityVO.getGoodId();
            //判斷是否存在
            if(redisService.exists(key)){
                maps= (Map) redisService.get(key);
                swHotelId = Integer.valueOf(maps.get("switchHotelId").toString());
                swRoomId = Integer.valueOf(maps.get("switchRoomId").toString());
            }else{
                SwitchCreateRoomEntity switchCreateRoomEntityNew = switchCreateRoomMapper.selectByMtGoodsIdAndHotelId(batchPushRoomDatasVo.getMtHotelId(), roomDataEntityVO.getGoodId());
                if(ObjectUtils.isEmpty(switchCreateRoomEntityNew) || ObjectUtils.isEmpty(switchCreateRoomEntityNew.getMasterHotelId())){
                    continue tab;
                }
                swHotelId = switchCreateRoomEntityNew.getHotelId();
                masterHotelId = switchCreateRoomEntityNew.getMasterHotelId();
                swRoomId = switchCreateRoomEntityNew.getRoomId();
                mtRoomId = switchCreateRoomEntityNew.getMtRoomId();
                maps=new HashMap();
                maps.put("switchHotelId", swHotelId);
                maps.put("switchMasterHotelId", masterHotelId);
                maps.put("switchRoomId", swRoomId);
                maps.put("mtRoomId", mtRoomId);
                redisService.set(key,maps);
            }
            //是否开启获取酒店有独立的价格公式
            if(redisService.exists(CommonConstants.SWITCH_IS_OPEN_HOTEL_OWNER_PRICE_FORMULA)){
                //获取酒店是否有自已独立的价格公式
                switchPriceBaseSetMap=getOnlinePriceSetByData(swHotelId,switchPriceBaseSetMap);
            }
            hotelId=swHotelId;
            //有价格变动数据
            if (!ObjectUtils.isEmpty(roomDataEntityVO.getRoomPrices()) && roomDataEntityVO.getRoomPrices().size() > 0) {
                //携程价格实体
                RoomPriceModelVo roomPriceModelVo=null;
                //去哪儿价格实体
                RoomPriceModelVo qunarRoomPriceModelVo = null;
                //b2b价格实体
                RoomPriceModelVo b2bRoomPriceModelVo =null;
                String switchHotelActiveTagVal="";
                String keys="";
                SwitchHotelActiveTagEntity switchHotelActiveTagEntity=null;
                int roomPirceSize=roomDataEntityVO.getRoomPrices().size();
                RoomPriceVo roomPriceVo=null;
                int j=0;
                double price=0.00;
                double priceBychannel=0.00;
                double addPrices=0.00;
                if(!ObjectUtils.isEmpty(addPrice)){
                    addPrices=addPrice.doubleValue()/100;
                }
                Map<String,Object> map=null;
                for (j=0;j<roomPirceSize;j++) {
                    roomPriceVo=roomDataEntityVO.getRoomPrices().get(j);
                    //携程
                    roomDataEntityVo = new RoomDataEntityVo();
                    roomDataEntityVo.setRoomId(swRoomId);
                    roomDataEntityVo.setStartDate(roomPriceVo.getDate());
                    roomDataEntityVo.setEndDate(roomPriceVo.getDate());
                    //去哪儿
                    qunarRoomDataEntityVo=new RoomDataEntityVo();
                    qunarRoomDataEntityVo.setRoomId(swRoomId);
                    qunarRoomDataEntityVo.setStartDate(roomPriceVo.getDate());
                    qunarRoomDataEntityVo.setEndDate(roomPriceVo.getDate());
                    //b2b
                    b2bRoomDataEntityVo=new RoomDataEntityVo();
                    b2bRoomDataEntityVo.setRoomId(swRoomId);
                    b2bRoomDataEntityVo.setStartDate(roomPriceVo.getDate());
                    b2bRoomDataEntityVo.setEndDate(roomPriceVo.getDate());
                    //channelA
                    channelRoomDataEntityVo=new RoomDataEntityVo();
                    channelRoomDataEntityVo.setRoomId(swRoomId);
                    channelRoomDataEntityVo.setStartDate(roomPriceVo.getDate());
                    channelRoomDataEntityVo.setEndDate(roomPriceVo.getDate());
                    //判断是否参加促销活动
                    keys=CommonConstants.SWITCH_HOTEL_ACTIVE_TAG+swHotelId+swRoomId;
                    switchHotelActiveTagEntity = new SwitchHotelActiveTagEntity();
                    if(redisService.exists(keys)){
                        switchHotelActiveTagVal = (String) redisService.get(keys);
                        switchHotelActiveTagEntity=GsonUtils.GsonToBean(switchHotelActiveTagVal,SwitchHotelActiveTagEntity.class);
                    }
                    //促销
                    map=new HashMap<>();
                    if( !ObjectUtils.isEmpty(switchHotelActiveTagEntity)&&!ObjectUtils.isEmpty(switchHotelActiveTagEntity.getStartTime())&&DateUtil.commpareDay(switchHotelActiveTagEntity.getStartTime(),roomPriceVo.getDate())&&DateUtil.commpareDay(roomPriceVo.getDate(),switchHotelActiveTagEntity.getEndTime())){
                        map=getPriceV2(switchPriceBaseSetMap,roomPriceVo.getSalePrice(),roomPriceVo.getSubPrice(),switchHotelActiveTagEntity);
                    }else{
                        map=getPriceV2(switchPriceBaseSetMap,roomPriceVo.getSalePrice(),roomPriceVo.getSubPrice(),null);
                    }
                    /**
                     * 计算携程推送价格
                     */
                    price = Double.parseDouble(map.get("ctripPrice").toString())+addPrices;
                    priceBychannel = Double.parseDouble(map.get("qunarPrice").toString())+addPrices;
                    //携程价格实体
                    roomPriceModelVo = new RoomPriceModelVo();
                    roomPriceModelVo.setRoomPrice(price);
                    roomPriceModelVo.setCurrency("CNY");
                    roomPriceModelVo.setChannel(channel);
                    roomDataEntityVo.setRoomPriceModel(roomPriceModelVo);
                    //去哪儿价格实体
                    qunarRoomPriceModelVo = new RoomPriceModelVo();
                    qunarRoomPriceModelVo.setRoomPrice(priceBychannel);
                    qunarRoomPriceModelVo.setCurrency("CNY");
                    qunarRoomPriceModelVo.setChannel(qunar);
                    qunarRoomDataEntityVo.setRoomPriceModel(qunarRoomPriceModelVo);
                    //b2b价格实体
                    b2bRoomPriceModelVo = new RoomPriceModelVo();
                    b2bRoomPriceModelVo.setRoomPrice(priceBychannel);
                    b2bRoomPriceModelVo.setCurrency("CNY");
                    b2bRoomPriceModelVo.setChannel(b2bChannel);
                    b2bRoomDataEntityVo.setRoomPriceModel(b2bRoomPriceModelVo);
                    //有库存房态变化
                    if (!ObjectUtils.isEmpty(roomDataEntityVO.getRoomStatusInventorys()) && roomDataEntityVO.getRoomStatusInventorys().size() > 0) {
                        roomDataEntityVo=getStatusInfo(batchPushRoomDatasVo.getTimestamp(),roomDataEntityVO.getRoomStatusInventorys(),channel,roomPriceVo.getDate(),roomDataEntityVo);
                    }
                    //推送价格记录表 保存房型推送数据实体数据
                    roomDataEntityVos.add(roomDataEntityVo);
                    roomDataEntityVos.add(qunarRoomDataEntityVo);
                    roomDataEntityVos.add(b2bRoomDataEntityVo);
                }

            } else {//说明只有库存和房态变化
                RoomStatusModelVo roomStatusModelVo=null;
                RoomInventoryModelVo roomInventoryModelVo=null;
                //设置房态房量
                for (RoomStatusInventory roomStatusInventory : roomDataEntityVO.getRoomStatusInventorys()) {
                    roomDataEntityVo = new RoomDataEntityVo();
                    roomDataEntityVo.setRoomId(swRoomId);
                    roomDataEntityVo.setStartDate(roomStatusInventory.getDate());
                    roomDataEntityVo.setEndDate(roomStatusInventory.getDate());
                    //房态
                    roomStatusModelVo = new RoomStatusModelVo();
                    roomStatusModelVo.setChannel(channel);
                    if (roomStatusInventory.getGoodStatus() == 1) {
                        roomInventoryModelVo=new RoomInventoryModelVo();
                        roomInventoryModelVo.setPreservedQuantity(0);
                        roomInventoryModelVo.setPushPreservedType(4);
                        roomInventoryModelVo.setUnPreservedQuantity(1);
                        roomInventoryModelVo.setPushUnPreservedType(4);
                        roomInventoryModelVo.setAutoCloseRoom(1);
                        roomInventoryModelVo.setChannel(channel);
                        roomStatusModelVo.setSaleStatus(SwitchSaleStatusEnums.SALE.getCode());
                        roomDataEntityVo.setRoomInventoryModel(roomInventoryModelVo);
                    } else {
                        roomInventoryModelVo=new RoomInventoryModelVo();
                        roomInventoryModelVo.setPreservedQuantity(0);
                        roomInventoryModelVo.setPushPreservedType(4);
                        roomInventoryModelVo.setUnPreservedQuantity(1);
                        roomInventoryModelVo.setPushUnPreservedType(4);
                        roomInventoryModelVo.setAutoCloseRoom(1);
                        roomInventoryModelVo.setChannel(channel);
                        roomDataEntityVo.setRoomInventoryModel(roomInventoryModelVo);
                        roomStatusModelVo.setSaleStatus(SwitchSaleStatusEnums.FULL.getCode());
                    }
                    roomDataEntityVo.setRoomStatusModel(roomStatusModelVo);
                    roomDataEntityVos.add(roomDataEntityVo);
                }
            }
        }
        String httpUrl=(profile.equals("test")? SwitchConstants.URL_TEST:SwitchConstants.URL_PROD)+"BatchPushRoomData";
        HttpPost httpPost = new HttpPost(httpUrl);
        batchPushRoomVo.setHotelId(hotelId);
        if(ObjectUtils.isEmpty(roomDataEntityVos)||roomDataEntityVos.size()<1){
            log.info("==============时间戳为{},推送的数据实体为空",batchPushRoomDatasVo.getTimestamp());
            return new Result<>("推送的数据实体为空");
        }
        List<List<RoomDataEntityVo>> RoomDataEntityVoLists= ListUtils.parititon(roomDataEntityVos,299);
        BaseRqeuestParam baseRqeuestParam=new BaseRqeuestParam();
        for(List<RoomDataEntityVo> roomDataEntityVos1:RoomDataEntityVoLists){
            batchPushRoomVo.setRoomDataEntitys(roomDataEntityVos1);
            Map<String,Object> requestParam=new HashMap<>();
            requestParam.put("roomDataEntitys",roomDataEntityVos);
            requestParam.put("hotelId",hotelId);
            try{
                CloseableHttpAsyncClient client=null;
                ObjectMapper objectMapper = new ObjectMapper();
                requestParam.put("requestor", baseRqeuestParam);
                int supplierID=profile.equals("test")? SwitchConstants.SUPPLIERID_TEST:SwitchConstants.SUPPLIERID_PROD;
                requestParam.put("supplierID", supplierID);
                //获取 timestamp
                String timestamp = String.valueOf(System.currentTimeMillis());
                //计算 signature
                key=profile.equals("test")?SwitchConstants.KEY_TEST:SwitchConstants.KEY_PROD;
                String tmp = String.valueOf(supplierID) + String.valueOf(System.currentTimeMillis()) + key;
                MessageDigest md5=MessageDigest.getInstance("MD5");
                BASE64Encoder base64en = new BASE64Encoder();
                String signature = base64en.encode(md5.digest(tmp.getBytes("utf-8"))).toUpperCase();
                //组装 http 请求数据
                httpPost.setHeader(HTTP.CONTENT_TYPE, "application/json");
                httpPost.setHeader("timestamp", timestamp);
                httpPost.setHeader("signature", signature);
                httpPost.setEntity(new StringEntity(objectMapper.writeValueAsString(requestParam),
                        ContentType.create("text/json", "UTF-8")));
                client = AsynHttpClientFactory.getCloseableHttpAsyncClient();
                final CountDownLatch latch = new CountDownLatch(1);
                client.execute(httpPost, new FutureCallback<HttpResponse>() {
                    @SneakyThrows
                    @Override
                    public void completed(HttpResponse httpResponse) {
                        latch.countDown();
                        log.info("=========时间戳为{}推送的数据为{}",batchPushRoomDatasVo.getTimestamp(),JacksonUtil.objectToJson(batchPushRoomVo));
                        HttpEntity httpEntity=httpResponse.getEntity();
                        String result = EntityUtils.toString(httpEntity);
                        log.info("请求的url是{}",httpUrl);
                        log.info("时间戳为{}请求数据是{}",batchPushRoomDatasVo.getTimestamp(),objectMapper.writeValueAsString(requestParam));
                        log.info("时间戳为{}result>>>>返回数据是{}",batchPushRoomDatasVo.getTimestamp(),result);
                        new MsgThread(batchPushRoomVo.getHotelId(),String.valueOf(roomDataEntityVos1.get(0).getRoomId()),batchPushRoomDatasVo.getMtHotelId(),batchPushRoomDatasVo.getTimestamp(),"时间戳为"+batchPushRoomDatasVo.getTimestamp()+result).run();
                        if(result.contains("太频繁")||result.contains("签名")){
                            redisService.lPush(MeituanConstants.REDIS_CHANGE_GOODS_DATA_MANY_HOTEL, JSON.toJSONString(batchPushRoomDatasVo));
                        }
                        int success=0;
                        if(redisService.exists("switch_push_price_and_status_size")){
                            success= (int) redisService.get("switch_push_price_and_status_size");
                        }
                        success=success+1;
                        redisService.set("switch_push_price_and_status_size",success);
                    }

                    @Override
                    public void failed(Exception e) {
                        latch.countDown();
                        log.info("=============httpResponse调用失败返回的信息为为{}=====",e.getMessage());
                    }

                    @Override
                    public void cancelled() {
                        latch.countDown();
                        log.info("=============httpResponse调用失败返回的信息为为=====");
                    }
                });
            }catch (Exception e ){
                e.printStackTrace();
                log.info("===================sendRequestByAsync调用携程出现异常======================");
            }

        }
        return new Result<>();

    }
    /***
    * @Author: lmf
    * @Date: 2021/3/2
     * 获取价格公式,如果有分配就使用分配的，没有就是使用默认的
    */
    private Map<String, List<SwitchPriceBaseSetEntity>> getOnlinePriceSetByData(int swHotelId, Map<String, List<SwitchPriceBaseSetEntity>> switchPriceBaseSetMap) {
        String keys=CommonConstants.SWITCH_HOTEL_PRICE_SET_RELATION;
        List<SwitchPriceBaseSetEntity> switchPriceBaseSetEntityByCtripChannel;
        int day=0;
        if(redisService.exists(CommonConstants.SWITCH_PRICE_SET_PRICE_TIME)){
            Integer time= (Integer) redisService.get(CommonConstants.SWITCH_PRICE_SET_PRICE_TIME);
            Calendar calendar=Calendar.getInstance();
            int hour=calendar.get(Calendar.HOUR_OF_DAY);
            if(hour>=time){
                day=1;
            }
        }
        String str= (String) redisService.hmGet(keys,swHotelId+ SwitchChannelNameEnums.CTRIP.getName());
        if(!StringUtils.isEmpty(str)){
            switchPriceBaseSetEntityByCtripChannel=JacksonUtil.jsonToList(str,SwitchPriceBaseSetEntity.class);
        }else{
            switchPriceBaseSetEntityByCtripChannel=switchPriceBaseSetMapper.selectByChannelNameAndHotelRelation(swHotelId,SwitchChannelNameEnums.CTRIP.getName(),day);
        }
        str= (String) redisService.hmGet(keys,swHotelId+ SwitchChannelNameEnums.QUNAR.getName());
        List<SwitchPriceBaseSetEntity> switchPriceBaseSetEntityByqunarChannel;
        if(!StringUtils.isEmpty(str)){
            switchPriceBaseSetEntityByqunarChannel=JacksonUtil.jsonToList(str,SwitchPriceBaseSetEntity.class);
        }else{
            switchPriceBaseSetEntityByqunarChannel=switchPriceBaseSetMapper.selectByChannelNameAndHotelRelation(swHotelId,SwitchChannelNameEnums.CTRIP.getName(),day);
        }
        if(!ObjectUtils.isEmpty(switchPriceBaseSetEntityByCtripChannel)&&switchPriceBaseSetEntityByCtripChannel.size()>0){
            switchPriceBaseSetMap.put(SwitchChannelNameEnums.CTRIP.getName(),switchPriceBaseSetEntityByCtripChannel);
            redisService.hmSet(keys,swHotelId+ SwitchChannelNameEnums.CTRIP.getName(),JacksonUtil.objectToJson(switchPriceBaseSetEntityByCtripChannel));
        }
        if(!ObjectUtils.isEmpty(switchPriceBaseSetEntityByqunarChannel)&&switchPriceBaseSetEntityByqunarChannel.size()>0){
            switchPriceBaseSetMap.put(SwitchChannelNameEnums.QUNAR.getName(),switchPriceBaseSetEntityByqunarChannel);
            redisService.hmSet(keys,swHotelId+ SwitchChannelNameEnums.QUNAR.getName(),JacksonUtil.objectToJson(switchPriceBaseSetEntityByCtripChannel));
        }
        return switchPriceBaseSetMap;
    }
    /***
    * @Author: lmf
    * @Date: 2021/4/20
     * 用来封装携程推送请求数据
    */
    public  Result<Object> constructionRequestData(BatchPushRoomDatasVo batchPushRoomDatasVo) {
        log.info("============进入封装数据时间戳为{}请求数据为{}=========================",batchPushRoomDatasVo.getTimestamp(),JSONUtils.toJSONString(batchPushRoomDatasVo));
        long startTime=System.currentTimeMillis();
        String channel = StringUtil.firstToUpperCase(SwitchChannelNameEnums.CTRIP.getName());
        String qunar = StringUtil.firstToUpperCase(SwitchChannelNameEnums.QUNAR.getName());
        String b2bChannel=StringUtil.firstToUpperCase(SwitchChannelNameEnums.BIG_B2B.getName());
        //获取携程子酒店信息
        List<RoomDataEntityVo> roomDataEntityVos=new ArrayList<>();
        Map<String, List<SwitchPriceBaseSetEntity>> switchPriceBaseSetMap=getOnlinePriceSet();
        //遍历美团产品列表
        int hotelId=0;
        int swHotelId=0;//携程酒店id
        int masterHotelId=0;//携程母酒店酒店id
        int swRoomId=0;//携程售卖房型id
        String mtRoomId="";//美团产品所属房型id
        //是否参与天天特价
        Integer addPrice= (Integer) redisService.hmGet(CommonConstants.SWITCH_JOIN_ACTIVE_HOTEL_LIST_FOR_ORDER,batchPushRoomDatasVo.getMtHotelId());
        //携程
        RoomDataEntityVo roomDataEntityVo = null;
        //去哪儿
        RoomDataEntityVo qunarRoomDataEntityVo=null;
        //b2b
        RoomDataEntityVo b2bRoomDataEntityVo=null;
        //channelA
        RoomDataEntityVo channelRoomDataEntityVo=null;
        //根据产品id + 美团的酒店id 获取数据
        String key="";
        int roomDataEntityListSize=batchPushRoomDatasVo.getRoomDataEntityList().size();
        RoomDataEntityVO roomDataEntityVO;
        int i=0;
        Map maps=null;
        tab:for(i=0;i<roomDataEntityListSize;i++) {
            roomDataEntityVO=batchPushRoomDatasVo.getRoomDataEntityList().get(i);
            //根据产品id + 美团的酒店id 获取数据
            key= CommonConstants.SWITCH_SELLING_REDIS_BY_MT+batchPushRoomDatasVo.getMtHotelId()+"_"+roomDataEntityVO.getGoodId();
            //判斷是否存在
            if(redisService.exists(key)){
                maps= (Map) redisService.get(key);
                swHotelId = Integer.valueOf(maps.get("switchHotelId").toString());
                swRoomId = Integer.valueOf(maps.get("switchRoomId").toString());
            }else{
                SwitchCreateRoomEntity switchCreateRoomEntityNew = switchCreateRoomMapper.selectByMtGoodsIdAndHotelId(batchPushRoomDatasVo.getMtHotelId(), roomDataEntityVO.getGoodId());
                if(ObjectUtils.isEmpty(switchCreateRoomEntityNew) || ObjectUtils.isEmpty(switchCreateRoomEntityNew.getMasterHotelId())){
                    continue tab;
                }
                swHotelId = switchCreateRoomEntityNew.getHotelId();
                masterHotelId = switchCreateRoomEntityNew.getMasterHotelId();
                swRoomId = switchCreateRoomEntityNew.getRoomId();
                mtRoomId = switchCreateRoomEntityNew.getMtRoomId();
                maps=new HashMap();
                maps.put("switchHotelId", swHotelId);
                maps.put("switchMasterHotelId", masterHotelId);
                maps.put("switchRoomId", swRoomId);
                maps.put("mtRoomId", mtRoomId);
                redisService.set(key,maps);
            }
            //是否开启获取酒店有独立的价格公式
            if(redisService.exists(CommonConstants.SWITCH_IS_OPEN_HOTEL_OWNER_PRICE_FORMULA)){
                //获取酒店是否有自已独立的价格公式
                switchPriceBaseSetMap=getOnlinePriceSetByData(swHotelId,switchPriceBaseSetMap);
            }
            hotelId=swHotelId;
            //有价格变动数据
            if (!ObjectUtils.isEmpty(roomDataEntityVO.getRoomPrices()) && roomDataEntityVO.getRoomPrices().size() > 0) {
                //携程价格实体
                RoomPriceModelVo roomPriceModelVo=null;
                //去哪儿价格实体
                RoomPriceModelVo qunarRoomPriceModelVo = null;
                //b2b价格实体
                RoomPriceModelVo b2bRoomPriceModelVo =null;
                //channel价格实体
                RoomPriceModelVo channelRoomPriceModelVo = null;
                String switchHotelActiveTagVal="";
                String keys="";
                SwitchHotelActiveTagEntity switchHotelActiveTagEntity=null;
                String currentWeekDay="";
                int roomPirceSize=roomDataEntityVO.getRoomPrices().size();
                RoomPriceVo roomPriceVo=null;
                int j=0;
                double price=0.00;
                double priceBychannel=0.00;
                Map<String,Object> map=null;
                double addPrices=0.00;
                if(!ObjectUtils.isEmpty(addPrice)){
                    addPrices=addPrice.doubleValue()/100;
                }
                String week = "";
                for (j=0;j<roomPirceSize;j++) {
                    roomPriceVo=roomDataEntityVO.getRoomPrices().get(j);
                    //携程
                    roomDataEntityVo = new RoomDataEntityVo();
                    roomDataEntityVo.setRoomId(swRoomId);
                    roomDataEntityVo.setStartDate(roomPriceVo.getDate());
                    roomDataEntityVo.setEndDate(roomPriceVo.getDate());
                    //去哪儿
                    qunarRoomDataEntityVo=new RoomDataEntityVo();
                    qunarRoomDataEntityVo.setRoomId(swRoomId);
                    qunarRoomDataEntityVo.setStartDate(roomPriceVo.getDate());
                    qunarRoomDataEntityVo.setEndDate(roomPriceVo.getDate());
                    //b2b
                    b2bRoomDataEntityVo=new RoomDataEntityVo();
                    b2bRoomDataEntityVo.setRoomId(swRoomId);
                    b2bRoomDataEntityVo.setStartDate(roomPriceVo.getDate());
                    b2bRoomDataEntityVo.setEndDate(roomPriceVo.getDate());
                    //channelA
                    channelRoomDataEntityVo=new RoomDataEntityVo();
                    channelRoomDataEntityVo.setRoomId(swRoomId);
                    channelRoomDataEntityVo.setStartDate(roomPriceVo.getDate());
                    channelRoomDataEntityVo.setEndDate(roomPriceVo.getDate());
                    //判断是否参加促销活动
                    keys=CommonConstants.SWITCH_HOTEL_ACTIVE_TAG+swHotelId+swRoomId;
                    switchHotelActiveTagEntity = new SwitchHotelActiveTagEntity();
                    if(redisService.exists(keys)){
                        switchHotelActiveTagVal = (String) redisService.get(keys);
                        switchHotelActiveTagEntity=GsonUtils.GsonToBean(switchHotelActiveTagVal,SwitchHotelActiveTagEntity.class);
                        week = switchHotelActiveTagEntity.getWeek();
                    }
                    //促销
                    map=new HashMap<>();
                    if( !ObjectUtils.isEmpty(switchHotelActiveTagEntity)&&!ObjectUtils.isEmpty(switchHotelActiveTagEntity.getStartTime())&&DateUtil.commpareDay(switchHotelActiveTagEntity.getStartTime(),roomPriceVo.getDate())&&DateUtil.commpareDay(roomPriceVo.getDate(),switchHotelActiveTagEntity.getEndTime())){
                        map=getPriceV2(switchPriceBaseSetMap,roomPriceVo.getSalePrice(),roomPriceVo.getSubPrice(),switchHotelActiveTagEntity);
                    }else{
                        map=getPriceV2(switchPriceBaseSetMap,roomPriceVo.getSalePrice(),roomPriceVo.getSubPrice(),null);
                    }
                    /**
                     * 计算携程推送价格
                     */
                    price = Double.parseDouble(map.get("ctripPrice").toString())+addPrices;
                    priceBychannel = Double.parseDouble(map.get("qunarPrice").toString())+addPrices;
                    //携程价格实体
                    roomPriceModelVo = new RoomPriceModelVo();
                    roomPriceModelVo.setRoomPrice(price);
                    roomPriceModelVo.setCurrency("CNY");
                    roomPriceModelVo.setChannel(channel);
                    roomDataEntityVo.setRoomPriceModel(roomPriceModelVo);
                    //去哪儿价格实体
                    qunarRoomPriceModelVo = new RoomPriceModelVo();
                    qunarRoomPriceModelVo.setRoomPrice(priceBychannel);
                    qunarRoomPriceModelVo.setCurrency("CNY");
                    qunarRoomPriceModelVo.setChannel(qunar);
                    qunarRoomDataEntityVo.setRoomPriceModel(qunarRoomPriceModelVo);
                    //b2b价格实体
                    b2bRoomPriceModelVo = new RoomPriceModelVo();
                    b2bRoomPriceModelVo.setRoomPrice(priceBychannel);
                    b2bRoomPriceModelVo.setCurrency("CNY");
                    b2bRoomPriceModelVo.setChannel(b2bChannel);
                    b2bRoomDataEntityVo.setRoomPriceModel(b2bRoomPriceModelVo);
                    //有库存房态变化
                    if (!ObjectUtils.isEmpty(roomDataEntityVO.getRoomStatusInventorys()) && roomDataEntityVO.getRoomStatusInventorys().size() > 0) {
                        roomDataEntityVo=getStatusInfo(batchPushRoomDatasVo.getTimestamp(),roomDataEntityVO.getRoomStatusInventorys(),channel,roomPriceVo.getDate(),roomDataEntityVo);
                    }
                    //推送价格记录表 保存房型推送数据实体数据
                    roomDataEntityVos.add(roomDataEntityVo);
                    roomDataEntityVos.add(qunarRoomDataEntityVo);
                    roomDataEntityVos.add(b2bRoomDataEntityVo);
                }
            } else {//说明只有库存和房态变化
                RoomStatusModelVo roomStatusModelVo=null;
                RoomInventoryModelVo roomInventoryModelVo=null;
                //设置房态房量
                for (RoomStatusInventory roomStatusInventory : roomDataEntityVO.getRoomStatusInventorys()) {
                    roomDataEntityVo = new RoomDataEntityVo();
                    roomDataEntityVo.setRoomId(swRoomId);
                    roomDataEntityVo.setStartDate(roomStatusInventory.getDate());
                    roomDataEntityVo.setEndDate(roomStatusInventory.getDate());
                    //房态
                    roomStatusModelVo = new RoomStatusModelVo();
                    roomStatusModelVo.setChannel(channel);
                    if (roomStatusInventory.getGoodStatus() == 1) {
                        roomInventoryModelVo=new RoomInventoryModelVo();
                        roomInventoryModelVo.setPreservedQuantity(0);
                        roomInventoryModelVo.setPushPreservedType(4);
                        roomInventoryModelVo.setUnPreservedQuantity(1);
                        roomInventoryModelVo.setPushUnPreservedType(4);
                        roomInventoryModelVo.setAutoCloseRoom(1);
                        roomInventoryModelVo.setChannel(channel);
                        roomStatusModelVo.setSaleStatus(SwitchSaleStatusEnums.SALE.getCode());
                        roomDataEntityVo.setRoomInventoryModel(roomInventoryModelVo);
                    } else {
                        roomInventoryModelVo=new RoomInventoryModelVo();
                        roomInventoryModelVo.setPreservedQuantity(0);
                        roomInventoryModelVo.setPushPreservedType(4);
                        roomInventoryModelVo.setUnPreservedQuantity(1);
                        roomInventoryModelVo.setPushUnPreservedType(4);
                        roomInventoryModelVo.setAutoCloseRoom(1);
                        roomInventoryModelVo.setChannel(channel);
                        roomDataEntityVo.setRoomInventoryModel(roomInventoryModelVo);
                        roomStatusModelVo.setSaleStatus(SwitchSaleStatusEnums.FULL.getCode());
                    }
                    roomDataEntityVo.setRoomStatusModel(roomStatusModelVo);
                    roomDataEntityVos.add(roomDataEntityVo);
                }
            }
        }
        BatchPushRoomDataVo batchPushRoomDataVo=null;
        BatchPushRoomVo batchPushRoomVo=new BatchPushRoomVo();
        batchPushRoomVo.setHotelId(hotelId);
        if(ObjectUtils.isEmpty(roomDataEntityVos)||roomDataEntityVos.size()<1){
            log.info("==============时间戳为{},推送的数据实体为空",batchPushRoomDatasVo.getTimestamp());
            return new Result<>("推送的数据实体为空");
        }
        List<List<RoomDataEntityVo>> RoomDataEntityVoLists= ListUtils.parititon(roomDataEntityVos,299);
        for(List<RoomDataEntityVo> roomDataEntityVos1:RoomDataEntityVoLists){
            batchPushRoomVo.setRoomDataEntitys(roomDataEntityVos1);
            log.info("=========时间戳为{}推送的数据为{}",batchPushRoomDatasVo.getTimestamp(),JacksonUtil.objectToJson(batchPushRoomVo));
            batchPushRoomDataVo=new BatchPushRoomDataVo();
            batchPushRoomDataVo.setTimeStamp(batchPushRoomDatasVo.getTimestamp());
            batchPushRoomDataVo.setBatchPushRoomVo(batchPushRoomVo);
            log.info("===========时间戳为{}封装成携程需要格式的数据为{}=====",batchPushRoomDatasVo.getTimestamp(),JacksonUtil.objectToJson(batchPushRoomDataVo));
            redisService.lPush(CommonConstants.SWITCH_CALLBACK_PUSH_DATA_QUEUE,GsonUtils.GsonString(batchPushRoomDataVo));
        }
        long endTime=System.currentTimeMillis();
        log.info("==========时间戳为{}封装的数据耗费时间为{}============",batchPushRoomDatasVo.getTimestamp(),(endTime-startTime));
        return new Result<>();
    }
    /**
     * 遍历获取房态信息,如果有推价格+房态
     */
    public RoomDataEntityVo getStatusInfo(String timeStamp,List<RoomStatusInventory> roomStatusInventories,String channel,String date,RoomDataEntityVo roomDataEntityVo){
        //设置房态房量
        RoomStatusModelVo roomStatusModelVo=null;
        int d=0;
        int roomStatusInventorySize= roomStatusInventories.size();
        RoomStatusInventory roomStatusInventory;
        //是否在15天之后，直接关房处理
        for (d=0;d<roomStatusInventorySize;d++) {
            roomStatusInventory= roomStatusInventories.get(d);
            //房态
            roomStatusModelVo = new RoomStatusModelVo();
            roomStatusModelVo.setChannel(channel);
            //可预定设置开售
            if(roomStatusInventory.getGoodStatus() == 1){
                roomStatusModelVo.setSaleStatus(SwitchSaleStatusEnums.SALE.getCode());
            }else{
                roomStatusModelVo.setSaleStatus(SwitchSaleStatusEnums.FULL.getCode());
            }
            roomDataEntityVo.setRoomStatusModel(roomStatusModelVo);
        }
        return roomDataEntityVo;
    }
    /**
     *
     * @author: lmf
     * @time: 2020/10/20 20:33
     * 异步存入数据库
     */
    class SaveLog implements  Runnable{
        private int hotelId;
        private int mtHotelId;
        private String timeStamp;

        public SaveLog(int hotelId, int mtHotelId, String timeStamp) {
            this.hotelId = hotelId;
            this.mtHotelId = mtHotelId;
            this.timeStamp = timeStamp;
        }

        @Override
        public void run() {
            switchRestTempaleUtilsService.pushSavePopLog(this.hotelId,this.mtHotelId,this.timeStamp);
        }
    }
    /***
    * @Author: lmf
    * @Date: 2021/3/16
     * 用来记录异步推送时间
    */
    class pushHotelLogThread implements Runnable{
        private Integer hotelId;

        public pushHotelLogThread(Integer hotelId) {
            this.hotelId = hotelId;
        }

        @Override
        public void run() {
            if(redisService.exists(CallbackConstants.REMOVE_GOODS_DATE_INFO_START)){
                String fullStatrtTime= (String) redisService.get(CallbackConstants.REMOVE_GOODS_DATE_INFO_START);
                String funllEndTime= (String) redisService.get(CallbackConstants.REMOVE_GOODS_DATE_INFO_END);
                SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                String nowTime=simpleDateFormat.format(new Date());
                if(DateUtil.commpareDay(fullStatrtTime,nowTime)&&DateUtil.commpareDay(nowTime,funllEndTime)){
                    //推送成功就推送数据
                    Map<String,Object> params=new HashMap<>();
                    params.put("hotelId",hotelId);
                    params.put("push",1);
                    switchRestTempaleUtilsService.pushHotelLog(params);
                }

            }
        }
    }
    /**
     * 异步推送钉钉消息
     */
    class MsgThread implements Runnable{
        private Integer hotelId;
        private String roomIds;
        private Integer mtHotelId;
        private String timeStamp;
        private String msg;

        public MsgThread(Integer hotelId, String roomIds, Integer mtHotelId, String timeStamp, String msg) {
            this.hotelId = hotelId;
            this.roomIds = roomIds;
            this.mtHotelId = mtHotelId;
            this.timeStamp = timeStamp;
            this.msg = msg;
        }

        @Override
        public void run() {
            //当前操作时间戳
            SimpleDateFormat ds=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date=new Date();
            String time=ds.format(date);
            log.info("===========异步推送给钉钉了=============");
            SendUtils.dingMsgNotLog(time+"直连推送报价等数据接口酒店id"+this.hotelId+"售卖房型id"+this.roomIds,"请求状态"+this.msg, MessageEnums.genre.ROOM_CHANGE_FOCUS.getCode(),restTemplate);
            switchRestTempaleUtilsService.pushSavePopLog(this.hotelId,this.mtHotelId,this.timeStamp);
        }
    }
    class MsgThreadBookThread implements Runnable{
        private String msg;

        public MsgThreadBookThread(String msg) {
            this.msg = msg;
        }

        @Override
        public void run() {
            SimpleDateFormat ds=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date=new Date();
            String time=ds.format(date);
            SendUtils.dingMsgNotLog(time+"推送价格房态",this.msg,MessageEnums.genre.ROOM_CHANGE_FOCUS.getCode(),restTemplate);
        }
    }

    /**
     * 获取酒店上架价格配置
     */
    public Map<String, List<SwitchPriceBaseSetEntity>> getOnlinePriceSet(){
        int day=0;
        if(redisService.exists(CommonConstants.SWITCH_PRICE_SET_PRICE_TIME)){
            Integer time= (Integer) redisService.get(CommonConstants.SWITCH_PRICE_SET_PRICE_TIME);
            Calendar calendar=Calendar.getInstance();
            int hour=calendar.get(Calendar.HOUR_OF_DAY);
            if(hour>=time){
                day=1;
            }
        }
        Map<String, List<SwitchPriceBaseSetEntity>> map=new HashMap<>();
        String key="switch_online_price_sets_up_by_"+ SwitchChannelNameEnums.CTRIP.getName();
        String qunarKey="switch_online_price_sets_up_by_"+SwitchChannelNameEnums.QUNAR.getName();
        List<SwitchPriceBaseSetEntity> switchPriceBaseSetEntityByCtripChannel;
       if(redisService.exists(key)){
           log.info("======走缓存获取ctrip上架价格配置==================");
           String str= (String) redisService.get(key);
           switchPriceBaseSetEntityByCtripChannel=JacksonUtil.jsonToList(str,SwitchPriceBaseSetEntity.class);
           // switchPriceBaseSetEntityByCtripChannel= (List<SwitchPriceBaseSetEntity>) redisService.get(key);
           log.info("======走缓存获取ctrip上架价格配置，switchPriceBaseSetEntityByCtripChannel的值为{}==================",JacksonUtil.objectToJson(switchPriceBaseSetEntityByCtripChannel));
        }else{
           log.info("======走数据库获取ctrip上架价格配置==================");
            switchPriceBaseSetEntityByCtripChannel=switchPriceBaseSetMapper.selectByChannelName(SwitchChannelNameEnums.CTRIP.getName(),day);
            redisService.set(key,JacksonUtil.objectToJson(switchPriceBaseSetEntityByCtripChannel),(long)20000);
        }
        List<SwitchPriceBaseSetEntity> switchPriceBaseSetEntityByQunarChannel;
        if(redisService.exists(qunarKey)){
            String str= (String) redisService.get(qunarKey);
            switchPriceBaseSetEntityByQunarChannel=JacksonUtil.jsonToList(str,SwitchPriceBaseSetEntity.class);
            log.info("======走缓存获取qunar上架价格配置,switchPriceBaseSetEntityByQunarChannel的值为{}==================",JacksonUtil.objectToJson(switchPriceBaseSetEntityByQunarChannel));
            //switchPriceBaseSetEntityByQunarChannel= (List<SwitchPriceBaseSetEntity>) redisService.get(qunarKey);
        }else{
            log.info("======走数据库获取qunar上架价格配置==================");
            switchPriceBaseSetEntityByQunarChannel=switchPriceBaseSetMapper.selectByChannelName(SwitchChannelNameEnums.QUNAR.getName(),day);
            redisService.set(qunarKey,JacksonUtil.objectToJson(switchPriceBaseSetEntityByQunarChannel),(long)20000);
        }
        map.put(SwitchChannelNameEnums.CTRIP.getName(),switchPriceBaseSetEntityByCtripChannel);
        map.put(SwitchChannelNameEnums.QUNAR.getName(),switchPriceBaseSetEntityByQunarChannel);
        return map;
    }

    /**
     * @author: lmf
     * @date: 2020/9/11 16:24
     * 是否参与天天特价活动，如果参与价格增加
     */
    private Map<String, Object> getPriceV2(Map<String, List<SwitchPriceBaseSetEntity>> priceSetMap, Integer salePrice, Integer subPrice,  SwitchHotelActiveTagEntity switchHotelActiveTagEntity) {
        Map<String,Object> map=new HashMap<>();
        //计算携程渠道价格
        double ctripPrice=salePrice.doubleValue()/100;
        double ctripRate=0;
        double ctripAddPrice=0;
        List<SwitchPriceBaseSetEntity> switchPriceBaseSetEntitiesByCtril=priceSetMap.get(SwitchChannelNameEnums.CTRIP.getName());
        for(SwitchPriceBaseSetEntity switchPriceBaseSetEntity:switchPriceBaseSetEntitiesByCtril){
            if(switchPriceBaseSetEntity.getMinPrice().doubleValue()<=ctripPrice&&ctripPrice<switchPriceBaseSetEntity.getMaxPrice().doubleValue()){
                ctripPrice=(salePrice.doubleValue()/100-subPrice.doubleValue()/100)*(1+switchPriceBaseSetEntity.getRate().doubleValue()/100)+switchPriceBaseSetEntity.getAddPrice().doubleValue();
                ctripRate=switchPriceBaseSetEntity.getRate().doubleValue();
                ctripAddPrice=switchPriceBaseSetEntity.getAddPrice().doubleValue();
            }
        }
        //计算去哪儿渠道价格
        double qunarPrice=salePrice.doubleValue()/100;
        double qunarRate=0;
        double qunarAddPrice=0;
        List<SwitchPriceBaseSetEntity> switchPriceBaseSetEntitiesByQunar=priceSetMap.get(SwitchChannelNameEnums.QUNAR.getName());
        for(SwitchPriceBaseSetEntity switchPriceBaseSetEntity:switchPriceBaseSetEntitiesByQunar){
            if(switchPriceBaseSetEntity.getMinPrice().doubleValue()<=qunarPrice&&qunarPrice<switchPriceBaseSetEntity.getMaxPrice().doubleValue()){
                qunarPrice=(salePrice.doubleValue()/100-subPrice.doubleValue()/100)*(1+switchPriceBaseSetEntity.getRate().doubleValue()/100)+switchPriceBaseSetEntity.getAddPrice().doubleValue();
                qunarRate=switchPriceBaseSetEntity.getRate().doubleValue();
                qunarAddPrice=switchPriceBaseSetEntity.getAddPrice().doubleValue();
            }
        }
        if(!ObjectUtils.isEmpty(switchHotelActiveTagEntity)){
            //促销方式是按折扣还是按金额
            if(switchHotelActiveTagEntity.getGenre()==0){
                qunarPrice= (qunarPrice*(1-switchHotelActiveTagEntity.getRate().doubleValue()/10))+qunarPrice;
                ctripPrice= (qunarPrice*(1-switchHotelActiveTagEntity.getRate().doubleValue()/10))+ctripPrice;
            }else{//按固定金额
                qunarPrice=qunarPrice+switchHotelActiveTagEntity.getRate().doubleValue();
                ctripPrice=ctripPrice+switchHotelActiveTagEntity.getRate().doubleValue();
            }
        }
        BigDecimal bg = new BigDecimal(ctripPrice);
        ctripPrice=bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
        BigDecimal bg2 = new BigDecimal(qunarPrice);
        qunarPrice=bg2.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
        map.put("ctripPrice",ctripPrice);
        map.put("ctripRate",ctripRate);
        map.put("ctripAddPrice",ctripAddPrice);
        map.put("qunarPrice",qunarPrice);
        map.put("qunarRate",qunarRate);
        map.put("qunarAddPrice",qunarAddPrice);
        return map;
    }

    /**
     * @author: lmf
     * @date: 2020/8/5 16:41
     * 调用携程的推送接口
     */
    public Result<Object> pushRoom(BatchPushRoomVo batchPushRoomVo, String timestamp){
        log.info("时间戳为{}---> 进入--pushRoom>>>",timestamp);
        if(batchPushRoomVo.getRoomDataEntitys().size()<1){
            return new Result<>("推送的实体数据为空");
        }
        //6.调用直连推送报价
        Result<Map<String,String>> result=switchRoomPriceService.batchPushRoomData(batchPushRoomVo);
        log.info("时间戳为{}pushRoom---result>>>>{}",timestamp,result);
    /*    if(result.getMsg().toString().contains("请求过于频繁")){
            try {
                Thread.sleep(200);
                result=switchRoomPriceService.batchPushRoomData(batchPushRoomVo);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }*/
        if(result.getCode()==CommonConstants.SUCCESS){
            return new Result<>();
        }else{
            return new Result<>(result.getMsg().toString());
        }
    }


    /**
     * 根据爬虫的数据更新房态数据
     * @return
     */
    @Override
    public Result<Object> notityModifyRoomInfoByManyThreadCallbackBySplider() {
        List<Future<Result<Object>>> threads=new ArrayList<>();
        BatchPushRoomDatasVo batchPushRoomDatasVo=new BatchPushRoomDatasVo();
        //线程数量
        String key=CommonConstants.SWITCH_PUSH_ROOM_THREAD_NUM_BY_SPLIDER;
        int num=4;
        if(redisService.exists(key)){
            num= (int) redisService.get(key);
        }else{
            redisService.set(key,4);
        }
        log.info("===========CallbackBySplider当前缓存中变化的数据长度为{},num={}",redisTemplate.opsForList().size(MeituanConstants.REDIS_CHANGE_GOODS_DATA_MANY_HOTEL_HHB_CHANNEL),num);
        for(int i=0;i<num;i++){
            log.info("CallbackBySplider i:{}缓存中没有可推送数据,长度为{}",i,redisTemplate.opsForList().size( MeituanConstants.REDIS_CHANGE_GOODS_DATA_MANY_HOTEL_HHB_CHANNEL));
            if(redisTemplate.opsForList().size(MeituanConstants.REDIS_CHANGE_GOODS_DATA_MANY_HOTEL_HHB_CHANNEL)==0){
                return new Result<>("缓存中没有可推送数据");
            }
            //String  batchPushRoomDatasVoStr= (String)redisTemplate.opsForList().rightPop( MeituanConstants.REDIS_CHANGE_GOODS_DATA_MANY_HOTEL_HHB_CHANNEL);
            String batchPushRoomDatasVoStr  ="{\"mtHotelId\":159622344,\"roomDataEntityList\":[{\"goodId\":22601816,\"goodInventory\":1,\"roomPrices\":[{\"date\":\"2020-09-14\",\"salePrice\":18000,\"subPrice\":0}]}]}";
            if(StringUtils.isEmpty(batchPushRoomDatasVoStr)){
                log.info("================CallbackBySplider缓存中没有可推送数据,batchPushRoomDatasVoStr为{}",batchPushRoomDatasVoStr);
                return new Result<>("缓存中没有可推送数据");
            }
            batchPushRoomDatasVo=JacksonUtil.parse(batchPushRoomDatasVoStr,BatchPushRoomDatasVo.class);
            if(ObjectUtils.isEmpty(batchPushRoomDatasVo)){
                log.info("================CallbackBySplider推送json字符串解析出错,batchPushRoomDatasVoStr为{}",batchPushRoomDatasVoStr);
                return new Result<>("推送json字符串解析出错");
            }
            log.info("CallbackBySplider定时器调用携程接口，处理价格房态更新，getTimestamp={},i={}",batchPushRoomDatasVo.getTimestamp(),i);
            try {
                Thread.sleep(5);
                threads.add(executor.submit(new spider("推送价格房态房态库存推送线程"+i,batchPushRoomDatasVo)));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        return new Result<>("推送房型价格库存房态数据成功");
    }
    /***
    * @Author: lmf
    * @Date: 2021/1/8
     * 推送价格房态
    */
    @Override
    public Result<Object> manyThreadPushRoomDataNew() {
        BatchPushRoomDatasVo batchPushRoomDatasVo = new BatchPushRoomDatasVo();
        long startTime = System.currentTimeMillis();
        //线程数量
        int num=20;
        ExecutorService executorService = Executors.newFixedThreadPool(num);
        List<Future<Result<Object>>> threads = new ArrayList<>();
        for (int i = 1; i <= num; i++) {
            String batchPushRoomDatasVoStr = "";
            synchronized (this) {
                //取数据问题
                batchPushRoomDatasVoStr = (String) redisTemplate.opsForList().rightPop(MeituanConstants.REDIS_CHANGE_GOODS_DATA_MANY_HOTEL);
            }
            log.info("================manyThreadPushRoomData缓存中可推送的数据长度为{}", redisTemplate.opsForList().size(MeituanConstants.REDIS_CHANGE_GOODS_DATA_MANY_HOTEL));
            //batchPushRoomDatasVoStr=" {\"mtHotelId\":1506619,\"timestamp\":\"16075727794200360150621\",\"roomDataEntityList\":[{\"goodId\":652738652,\"goodInventory\":1,\"roomStatusInventorys\":[{\"goodStatus\":2,\"date\":\"2020-12-09\"},{\"goodStatus\":1,\"date\":\"2020-12-10\"},{\"goodStatus\":1,\"date\":\"2020-12-11\"},{\"goodStatus\":1,\"date\":\"2020-12-12\"},{\"goodStatus\":1,\"date\":\"2020-12-13\"},{\"goodStatus\":1,\"date\":\"2020-12-14\"},{\"goodStatus\":1,\"date\":\"2020-12-15\"},{\"goodStatus\":1,\"date\":\"2020-12-16\"},{\"goodStatus\":1,\"date\":\"2020-12-17\"},{\"goodStatus\":1,\"date\":\"2020-12-18\"},{\"goodStatus\":1,\"date\":\"2020-12-19\"},{\"goodStatus\":1,\"date\":\"2020-12-20\"},{\"goodStatus\":1,\"date\":\"2020-12-21\"},{\"goodStatus\":1,\"date\":\"2020-12-22\"},{\"goodStatus\":1,\"date\":\"2020-12-23\"},{\"goodStatus\":1,\"date\":\"2020-12-24\"},{\"goodStatus\":1,\"date\":\"2020-12-25\"},{\"goodStatus\":1,\"date\":\"2020-12-26\"},{\"goodStatus\":1,\"date\":\"2020-12-27\"},{\"goodStatus\":1,\"date\":\"2020-12-28\"},{\"goodStatus\":1,\"date\":\"2020-12-29\"},{\"goodStatus\":1,\"date\":\"2020-12-30\"},{\"goodStatus\":1,\"date\":\"2020-12-31\"},{\"goodStatus\":1,\"date\":\"2021-01-01\"},{\"goodStatus\":1,\"date\":\"2021-01-02\"},{\"goodStatus\":1,\"date\":\"2021-01-03\"},{\"goodStatus\":1,\"date\":\"2021-01-04\"},{\"goodStatus\":1,\"date\":\"2021-01-05\"},{\"goodStatus\":1,\"date\":\"2021-01-06\"},{\"goodStatus\":1,\"date\":\"2021-01-07\"},{\"goodStatus\":1,\"date\":\"2021-01-08\"}]},{\"goodId\":1802305,\"goodInventory\":1,\"roomStatusInventorys\":[{\"goodStatus\":2,\"date\":\"2020-12-09\"},{\"goodStatus\":1,\"date\":\"2020-12-10\"},{\"goodStatus\":1,\"date\":\"2020-12-11\"},{\"goodStatus\":1,\"date\":\"2020-12-12\"},{\"goodStatus\":1,\"date\":\"2020-12-13\"},{\"goodStatus\":1,\"date\":\"2020-12-14\"},{\"goodStatus\":1,\"date\":\"2020-12-15\"},{\"goodStatus\":1,\"date\":\"2020-12-16\"},{\"goodStatus\":1,\"date\":\"2020-12-17\"},{\"goodStatus\":1,\"date\":\"2020-12-18\"},{\"goodStatus\":1,\"date\":\"2020-12-19\"},{\"goodStatus\":1,\"date\":\"2020-12-20\"},{\"goodStatus\":1,\"date\":\"2020-12-21\"},{\"goodStatus\":1,\"date\":\"2020-12-22\"},{\"goodStatus\":1,\"date\":\"2020-12-23\"},{\"goodStatus\":1,\"date\":\"2020-12-24\"},{\"goodStatus\":1,\"date\":\"2020-12-25\"},{\"goodStatus\":1,\"date\":\"2020-12-26\"},{\"goodStatus\":1,\"date\":\"2020-12-27\"},{\"goodStatus\":1,\"date\":\"2020-12-28\"},{\"goodStatus\":1,\"date\":\"2020-12-29\"},{\"goodStatus\":1,\"date\":\"2020-12-30\"},{\"goodStatus\":1,\"date\":\"2020-12-31\"},{\"goodStatus\":1,\"date\":\"2021-01-01\"},{\"goodStatus\":1,\"date\":\"2021-01-02\"},{\"goodStatus\":1,\"date\":\"2021-01-03\"},{\"goodStatus\":1,\"date\":\"2021-01-04\"},{\"goodStatus\":1,\"date\":\"2021-01-05\"},{\"goodStatus\":1,\"date\":\"2021-01-06\"},{\"goodStatus\":1,\"date\":\"2021-01-07\"},{\"goodStatus\":1,\"date\":\"2021-01-08\"}]},{\"goodId\":3614572,\"goodInventory\":1,\"roomStatusInventorys\":[{\"goodStatus\":2,\"date\":\"2020-12-09\"},{\"goodStatus\":1,\"date\":\"2020-12-10\"},{\"goodStatus\":1,\"date\":\"2020-12-11\"},{\"goodStatus\":1,\"date\":\"2020-12-12\"},{\"goodStatus\":1,\"date\":\"2020-12-13\"},{\"goodStatus\":1,\"date\":\"2020-12-14\"},{\"goodStatus\":1,\"date\":\"2020-12-15\"},{\"goodStatus\":1,\"date\":\"2020-12-16\"},{\"goodStatus\":1,\"date\":\"2020-12-17\"},{\"goodStatus\":1,\"date\":\"2020-12-18\"},{\"goodStatus\":1,\"date\":\"2020-12-19\"},{\"goodStatus\":1,\"date\":\"2020-12-20\"},{\"goodStatus\":1,\"date\":\"2020-12-21\"},{\"goodStatus\":1,\"date\":\"2020-12-22\"},{\"goodStatus\":1,\"date\":\"2020-12-23\"},{\"goodStatus\":1,\"date\":\"2020-12-24\"},{\"goodStatus\":1,\"date\":\"2020-12-25\"},{\"goodStatus\":1,\"date\":\"2020-12-26\"},{\"goodStatus\":1,\"date\":\"2020-12-27\"},{\"goodStatus\":1,\"date\":\"2020-12-28\"},{\"goodStatus\":1,\"date\":\"2020-12-29\"},{\"goodStatus\":1,\"date\":\"2020-12-30\"},{\"goodStatus\":1,\"date\":\"2020-12-31\"},{\"goodStatus\":1,\"date\":\"2021-01-01\"},{\"goodStatus\":1,\"date\":\"2021-01-02\"},{\"goodStatus\":1,\"date\":\"2021-01-03\"},{\"goodStatus\":1,\"date\":\"2021-01-04\"},{\"goodStatus\":1,\"date\":\"2021-01-05\"},{\"goodStatus\":1,\"date\":\"2021-01-06\"},{\"goodStatus\":1,\"date\":\"2021-01-07\"},{\"goodStatus\":1,\"date\":\"2021-01-08\"}]},{\"goodId\":1802279,\"goodInventory\":1,\"roomStatusInventorys\":[{\"goodStatus\":2,\"date\":\"2020-12-09\"},{\"goodStatus\":1,\"date\":\"2020-12-10\"},{\"goodStatus\":1,\"date\":\"2020-12-11\"},{\"goodStatus\":1,\"date\":\"2020-12-12\"},{\"goodStatus\":1,\"date\":\"2020-12-13\"},{\"goodStatus\":1,\"date\":\"2020-12-14\"},{\"goodStatus\":1,\"date\":\"2020-12-15\"},{\"goodStatus\":1,\"date\":\"2020-12-16\"},{\"goodStatus\":1,\"date\":\"2020-12-17\"},{\"goodStatus\":1,\"date\":\"2020-12-18\"},{\"goodStatus\":1,\"date\":\"2020-12-19\"},{\"goodStatus\":1,\"date\":\"2020-12-20\"},{\"goodStatus\":1,\"date\":\"2020-12-21\"},{\"goodStatus\":1,\"date\":\"2020-12-22\"},{\"goodStatus\":1,\"date\":\"2020-12-23\"},{\"goodStatus\":1,\"date\":\"2020-12-24\"},{\"goodStatus\":1,\"date\":\"2020-12-25\"},{\"goodStatus\":1,\"date\":\"2020-12-26\"},{\"goodStatus\":1,\"date\":\"2020-12-27\"},{\"goodStatus\":1,\"date\":\"2020-12-28\"},{\"goodStatus\":1,\"date\":\"2020-12-29\"},{\"goodStatus\":1,\"date\":\"2020-12-30\"},{\"goodStatus\":1,\"date\":\"2020-12-31\"},{\"goodStatus\":1,\"date\":\"2021-01-01\"},{\"goodStatus\":1,\"date\":\"2021-01-02\"},{\"goodStatus\":1,\"date\":\"2021-01-03\"},{\"goodStatus\":1,\"date\":\"2021-01-04\"},{\"goodStatus\":1,\"date\":\"2021-01-05\"},{\"goodStatus\":1,\"date\":\"2021-01-06\"},{\"goodStatus\":1,\"date\":\"2021-01-07\"},{\"goodStatus\":1,\"date\":\"2021-01-08\"}]}]}";
            if (StringUtils.isEmpty(batchPushRoomDatasVoStr)) {
                break;
            }
            batchPushRoomDatasVo = JacksonUtil.parse(batchPushRoomDatasVoStr, BatchPushRoomDatasVo.class);
            if (ObjectUtils.isEmpty(batchPushRoomDatasVo)) {
                break;
            }
            Future<Result<Object>> result = executorService.submit(new spiderNew("推送价格房态房态库存推送线程" + i, batchPushRoomDatasVo));
            threads.add(result);
        }
        executorService.shutdown();
        long endTime=System.currentTimeMillis();
        while(true){
            if(executorService.isTerminated()){
                log.info("====执行结束了======");
                break;
            }
        }
        log.info("===========整个推送花费推送花费的时间为{}",(endTime-startTime));
        return new Result<>("推送房型价格库存房态数据成功");
    }

    @Override
    public Result<Object> manyThreadPushRoomDataByTest() {
        BatchPushRoomDatasVo batchPushRoomDatasVo = new BatchPushRoomDatasVo();
        String  batchPushRoomDatasVoStr="{\"mtHotelId\":175460416,\"roomDataEntityList\":[{\"goodId\":64113066,\"goodInventory\":1,\"roomPrices\":[{\"date\":\"2021-01-29\",\"salePrice\":20800,\"subPrice\":1040},{\"date\":\"2021-01-30\",\"salePrice\":20800,\"subPrice\":1040}]},{\"goodId\":64113068,\"goodInventory\":1,\"roomPrices\":[{\"date\":\"2021-01-30\",\"salePrice\":35800,\"subPrice\":1790},{\"date\":\"2021-01-29\",\"salePrice\":35800,\"subPrice\":1790}]}],\"timestamp\":\"16118582222666052175411\"}";
        if (StringUtils.isEmpty(batchPushRoomDatasVoStr)) {
           return new Result<>();
        }
        batchPushRoomDatasVo = JacksonUtil.parse(batchPushRoomDatasVoStr, BatchPushRoomDatasVo.class);
        if (ObjectUtils.isEmpty(batchPushRoomDatasVo)) {
            return new Result<>();
        }
        ExecutorService executorService = Executors.newFixedThreadPool(1);
        List<Future<Result<Object>>> threads = new ArrayList<>();
        Future<Result<Object>> result = executorService.submit(new spider("推送价格房态房态库存推送线程" + 1, batchPushRoomDatasVo));
        threads.add(result);
        return null;
    }

    /**
     * 使用内部类用来处理推送价格
     */
    class spiderNew implements Callable<Result<Object>> {
        String threadName;
        BatchPushRoomDatasVo batchPushRoomDatasVo;

        public spiderNew(String threadName,BatchPushRoomDatasVo batchPushRoomDatasVo) {
            this.threadName = threadName;
            this.batchPushRoomDatasVo=batchPushRoomDatasVo;

        }
        @Override
        public Result<Object> call() {
            return constructionRequestData(batchPushRoomDatasVo);
        }
    }

}

